package com.yanqu.road.entity.activity.dafuweng;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

@FieldTypeAnnotation(tableName = "t_u_dfw_user_data")
public class DFWUserData extends DataObject {

    @FieldTypeAnnotation(desc = "用户ID")
    private long userId;
    @FieldTypeAnnotation(desc = "活动ID")
    private int activityId;

    @FieldTypeAnnotation(desc = "金币积分")
    private int goldScore;

    @FieldTypeAnnotation(desc = "格子下标")
    private int positionIndex;

    @FieldTypeAnnotation(desc = "人偶ID")
    private int dollId;

    @FieldTypeAnnotation(desc = "坐骑ID")
    private int vehicleId;
    @FieldTypeAnnotation(desc = "坐骑剩余移动次数")
    private int vehicleMoveTimes;

    @FieldTypeAnnotation(desc = "体力")
    private int energy;
    @FieldTypeAnnotation(desc = "上次恢复时间")
    private long lastRecoveryTime;

    @FieldTypeAnnotation(desc = "格子是否完成")
    private boolean complete;

    @FieldTypeAnnotation(desc = "碰到boss免费战斗次数")
    private int freeBattleTimes;

    @FieldTypeAnnotation(desc = "人偶数据")
    private List<DFWDollData> dollList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "佣兵卡使用次数")
    private int yongBingTimes;

    @FieldTypeAnnotation(desc = "密道数据")
    private List<DFWUserSecretRoad> userSecretRoadList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "造谣选项")
    private List<DFWZaoYaoOptional> zaoYaoOptionalList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "商会贸易奖励领取次数（道具id，次数）")
    private Map<Integer, Integer> rewardCollectionMap = new ConcurrentHashMap<>();

    @FieldTypeAnnotation(desc = "路障数据")
    private List<LuZhangData> luZhangDataList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "当前事件ID")
    private int eventId;

    @FieldTypeAnnotation(desc = "拓展参数")
    // boss事件：bossId
    // 密道事件：positionIndex
    private String expandParam = "";
    @FieldTypeAnnotation(desc = "现金礼包id列表")
    private List<Integer> moneyMallList = new ArrayList<>();
    @FieldTypeAnnotation(desc = "商会返利领奖记录")
    private List<Integer> rebateRewardRecord = new ArrayList<>();
    @FieldTypeAnnotation(desc = "金宝箱开启次数")
    private int boxOpenTimes;

    @FieldTypeAnnotation(desc = "重置时间")
    private long lastResetTime;

    @FieldTypeAnnotation(desc = "神仙数据")
    private List<DFWGodData> dfwGodDataList = new ArrayList<>();

    @FieldTypeAnnotation(desc = "总伤害")
    private int totalDamage;

    private List<DFWZaoYaoOptional> zaoYaoCardOptionalList = new ArrayList<>();

    private List<DfwPackageData> packageList = new ArrayList<>();

    // 预扣除参数，不入库
    private int preFreeBattleTimes = 0;
    private int preYongBingTimes = 0;

    //攻击boss频率
    private long lastAttackBossTime;

    //是否分享成功
    private boolean isShareSuccess;

    //上次设置事件id的时间
    private long lastSetEventTime;

    // 冗余下宝箱事件时加入背包的道具
    private String boxEventBagReward = "";

    private boolean tenRoll;

    public String getBoxEventBagReward() {
        return boxEventBagReward;
    }

    public void setBoxEventBagReward(String boxEventBagReward) {
        this.boxEventBagReward = boxEventBagReward;
    }

    public long getLastSetEventTime() {
        return lastSetEventTime;
    }

    public long getLastResetTime() {
        return lastResetTime;
    }

    public void setLastResetTime(long lastResetTime) {
        if (this.lastResetTime != lastResetTime) {
            this.lastResetTime = lastResetTime;
            setUpdateOption();
        }
    }

    public boolean isShareSuccess() {
        return isShareSuccess;
    }

    public void setShareSuccess(boolean shareSuccess) {
        isShareSuccess = shareSuccess;
    }

    public int getTotalDamage() {
        return totalDamage;
    }

    public void setTotalDamage(int totalDamage) {
        if (totalDamage != this.totalDamage) {
            this.totalDamage = totalDamage;
            setUpdateOption();
        }
    }

    public int getBoxOpenTimes() {
        return boxOpenTimes;
    }

    public void setBoxOpenTimes(int boxOpenTimes) {
        if (this.boxOpenTimes != boxOpenTimes) {
            this.boxOpenTimes = boxOpenTimes;
            setUpdateOption();
        }
    }

    public long getLastAttackBossTime() {
        return lastAttackBossTime;
    }

    public void setLastAttackBossTime(long lastAttackBossTime) {
        this.lastAttackBossTime = lastAttackBossTime;
    }

    public void setUserId(long userId) {
        this.userId = userId;
    }

    public void setActivityId(int activityId) {
        this.activityId = activityId;
    }

    public void setGoldScore(int goldScore) {
        if (goldScore != this.goldScore) {
            this.goldScore = goldScore;
            setUpdateOption();
        }
    }

    public void setPositionIndex(int positionIndex) {
        if (positionIndex != this.positionIndex) {
            this.positionIndex = positionIndex;
            setUpdateOption();
        }

    }

    public void setDollId(int dollId) {
        if (dollId != this.dollId) {
            this.dollId = dollId;
            setUpdateOption();
        }
    }

    public void setVehicleId(int vehicleId) {
        if (vehicleId != this.vehicleId) {
            this.vehicleId = vehicleId;
            setUpdateOption();
        }
    }

    public void setVehicleMoveTimes(int vehicleMoveTimes) {
        if (vehicleMoveTimes != this.vehicleMoveTimes) {
            this.vehicleMoveTimes = vehicleMoveTimes;
            setUpdateOption();
        }
    }

    public void setEnergy(int energy) {
        if (energy != this.energy) {
            this.energy = energy;
            setUpdateOption();
        }
    }

    public void setLastRecoveryTime(long lastRecoveryTime) {
        if (lastRecoveryTime != this.lastRecoveryTime) {
            this.lastRecoveryTime = lastRecoveryTime;
            setUpdateOption();
        }
    }

    public void setComplete(boolean complete) {
        if (complete != this.complete) {
            this.complete = complete;
            setUpdateOption();
        }
    }

    public void setFreeBattleTimes(int freeBattleTimes) {
        if (freeBattleTimes != this.freeBattleTimes) {
            this.freeBattleTimes = freeBattleTimes;
            setUpdateOption();
        }
    }

    public void setDollList(List<DFWDollData> dollList) {
        this.dollList = dollList;
        setUpdateOption();
    }

    public void setYongBingTimes(int yongBingTimes) {
        if (yongBingTimes != this.yongBingTimes) {
            this.yongBingTimes = yongBingTimes;
            setUpdateOption();
        }
    }

    public void setUserSecretRoadList(List<DFWUserSecretRoad> userSecretRoadList) {
        this.userSecretRoadList = userSecretRoadList;
        setUpdateOption();
    }

    public void setZaoYaoOptionalList(List<DFWZaoYaoOptional> zaoYaoOptionalList) {
        this.zaoYaoOptionalList = zaoYaoOptionalList;
        setUpdateOption();
    }

    public void setRewardCollectionMap(Map<Integer, Integer> rewardCollectionMap) {
        this.rewardCollectionMap = rewardCollectionMap;
        setUpdateOption();
    }

    public void setLuZhangDataList(List<LuZhangData> luZhangDataList) {
        this.luZhangDataList = luZhangDataList;
        setUpdateOption();
    }

    public void setEventId(int eventId) {
        this.lastSetEventTime = System.currentTimeMillis();
        if (eventId != this.eventId) {
            this.eventId = eventId;
            setUpdateOption();
        }
    }

    public void setExpandParam(String expandParam) {
        if (!this.expandParam.equals(expandParam)) {
            this.expandParam = expandParam;
            setUpdateOption();
        }
    }

    public void setMoneyMallList(List<Integer> moneyMallList) {
        this.moneyMallList = moneyMallList;
        setUpdateOption();
    }

    public void setRebateRewardRecord(List<Integer> rebateRewardRecord) {
        this.rebateRewardRecord = rebateRewardRecord;
        setUpdateOption();
    }

    public List<DFWGodData> getDfwGodDataList() {
        return dfwGodDataList;
    }

    public void setDfwGodDataList(List<DFWGodData> dfwGodDataList) {
        this.dfwGodDataList = dfwGodDataList;
        setUpdateOption();
    }

    public void setPreFreeBattleTimes(int preFreeBattleTimes) {
        this.preFreeBattleTimes = preFreeBattleTimes;
    }

    public void setPreYongBingTimes(int preYongBingTimes) {
        this.preYongBingTimes = preYongBingTimes;
    }

    public long getUserId() {
        return userId;
    }

    public int getActivityId() {
        return activityId;
    }

    public int getGoldScore() {
        return goldScore;
    }

    public int getPositionIndex() {
        return positionIndex;
    }

    public int getDollId() {
        return dollId;
    }

    public int getVehicleId() {
        return vehicleId;
    }

    public int getVehicleMoveTimes() {
        return vehicleMoveTimes;
    }

    public int getEnergy() {
        return energy;
    }

    public long getLastRecoveryTime() {
        return lastRecoveryTime;
    }

    public boolean isComplete() {
        return complete;
    }

    public int getFreeBattleTimes() {
        return freeBattleTimes;
    }

    public List<DFWDollData> getDollList() {
        return dollList;
    }

    public int getYongBingTimes() {
        return yongBingTimes;
    }

    public List<DFWUserSecretRoad> getUserSecretRoadList() {
        return userSecretRoadList;
    }

    public List<DFWZaoYaoOptional> getZaoYaoOptionalList() {
        return zaoYaoOptionalList;
    }

    public Map<Integer, Integer> getRewardCollectionMap() {
        return rewardCollectionMap;
    }

    public List<LuZhangData> getLuZhangDataList() {
        return luZhangDataList;
    }

    public int getEventId() {
        return eventId;
    }

    public String getExpandParam() {
        return expandParam;
    }

    public List<Integer> getMoneyMallList() {
        return moneyMallList;
    }

    public List<Integer> getRebateRewardRecord() {
        return rebateRewardRecord;
    }

    public int getPreFreeBattleTimes() {
        return preFreeBattleTimes;
    }

    public int getPreYongBingTimes() {
        return preYongBingTimes;
    }

    public List<DFWZaoYaoOptional> getZaoYaoCardOptionalList() {
        return zaoYaoCardOptionalList;
    }

    public void setZaoYaoCardOptionalList(List<DFWZaoYaoOptional> zaoYaoCardOptionalList) {
        this.zaoYaoCardOptionalList = zaoYaoCardOptionalList;
        setUpdateOption();
    }

    public List<DfwPackageData> getPackageList() {
        return packageList;
    }

    public void setPackageList(List<DfwPackageData> packageList) {
        if (!Objects.equals(this.packageList, packageList)) {
            this.packageList = packageList;
            setUpdateOption();
        }
    }

    public void addPackage(int mallId, int type) {
        DfwPackageData packageData = null;
        for (DfwPackageData data : packageList) {
            if (data.getMallId() == mallId && data.getType() == type) {
                packageData = data;
            }
        }
        if (packageData == null) {
            packageData = new DfwPackageData();
            packageData.setMallId(mallId);
            packageData.setType(type);
            packageList.add(packageData);
        }
        packageData.setNum(packageData.getNum() + 1);
        setUpdateOption();
    }

    public void reducePackage(int mallId, int type) {
        DfwPackageData packageData = null;
        for (DfwPackageData data : packageList) {
            if (data.getMallId() == mallId && data.getType() == type) {
                packageData = data;
            }
        }
        if (packageData == null) {
            return;
        }
        if (packageData.getNum() > 0) {
            packageData.setNum(packageData.getNum() - 1);
            setUpdateOption();
        }
    }

    public DfwPackageData getPackageData(int mallId) {
        for (DfwPackageData data : packageList) {
            if (data.getMallId() == mallId) {
                return data;
            }
        }
        return null;
    }

    public boolean isTenRoll() {
        return tenRoll;
    }

    public void setTenRoll(boolean tenRoll) {
        this.tenRoll = tenRoll;
    }
}
